﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DOMercury.Interfaces;
using DOMercury.Items;
using DOMercury.Engine;

namespace Bezel__
{
    
    public class IItemWrapper : IItem
    {
        private BitmapSource icon;
        private IItem innerItem;
        private bool hasSubIndex;
        #region IItem Members

        public IItemWrapper(IItem InnerItem)
        {
            innerItem = InnerItem;
            hasSubIndex = DOMercury.Engine.Interface.EngineCore.HasSubIndex(this.ItemType);
        }

        public int CompareTo(object obj)
        {
            return innerItem.CompareTo(obj);
        }

        public bool HasSubIndex
        {
            get
            {
                return hasSubIndex;
            }
        }

        public string DisplayDesc
        {
            get { return innerItem.DisplayDesc; }
        }

        public string DisplayName
        {
            get { return innerItem.DisplayName; }
        }

        public string ItemType
        {
            get { return innerItem.ItemType; }
        }

        public BitmapSource Icon
        {
            get
            {
                if (icon == null)
                {
                    icon = Interface.EngineCore.GetIconImageWPF(DisplayDesc);
                }
                return icon;
            }
            
        }

        public IItem InnerItem
        {
            get
            {
                return innerItem;
            }
        }

        public override string ToString()
        {
            return DisplayName;
        }

        private System.Windows.Media.Imaging.BitmapSource FromBitmap(System.Drawing.Bitmap bitmap)
        {
            if (bitmap != null)
            {
                return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                bitmap.GetHbitmap(),
                IntPtr.Zero,
                System.Windows.Int32Rect.Empty,
                System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
            }
            else
            {
                return null;
            }
        }

        #endregion

    }

    public class IActionWrapper : IAction
    {
        private BitmapSource icon;
        private IAction innerAction;
        

        public BitmapSource Icon
        {
            get
            {
                if (icon == null)
                {
                    icon = Interface.EngineCore.GetIconImageWPF(ActionType);
                }
                return icon;
            }
        }


        public IActionWrapper(IAction action)
        {
            innerAction = action;
           
          
        }

        public IAction InnerAction
        {
            get
            {
                return innerAction;
            }
        }

        public override string ToString()
        {
            return ActionType;
        }

        #region IAction Members

        public string ActionType
        {
            get { return innerAction.ActionType; }
        }

        public string Description
        {
            get { return innerAction.Description; }
        }

        public string ParamDescription
        {
            get { return innerAction.ParamDescription; }
        }

        public string ParameterType
        {
            get { return innerAction.ParameterType; }
        }

        public bool Perform(IItem item, object specialParams)
        {
            return innerAction.Perform(item, specialParams);
        }

        #endregion
    }
    
}
